﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WG计划管理工具
{
    public partial class frmLogin : Form
    {
        SqlTools.SqlTools sqt;

        public frmLogin()
        {
            InitializeComponent();
        }

        private void frmLogin_Load(object sender, EventArgs e)
        {
            sqt = new SqlTools.SqlTools(WG计划管理工具.Properties.Settings.Default.ConnectionString);
            txtUserID.Focus();
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (txtUserID .Text .Trim ().Length ==0)
            {
                clsTools.ShowWarningMsg ("用户名不能为空！");
                txtUserID .Focus ();
                return ;
            }
            string strCheckPassword = "select yh002 from yh_table where yh001='" + txtUserID.Text + "' and yh005='" + txtPassword.Text + "'";
            if (sqt.RecordExist(strCheckPassword))
            {
                frmMain newFrmMain = new frmMain(txtUserID.Text);
                newFrmMain.Owner  = this;
                newFrmMain.StartPosition = FormStartPosition.CenterScreen;
                newFrmMain.Show();
                txtUserID.Clear();
                txtPassword.Clear();
                this.Hide();
            }
            else
            {
                clsTools.ShowErrMsg("用户名或密码错误！");
                txtUserID.Focus();
            }
        }
    }
}